package com.zhima.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhima.entity.OjJudgeRecord;

public enum SortType {
    /**
     * 最新提交
     * 按时间降序
     */
    NEWEST("Newest") {
        @Override
        public void addCondition(LambdaQueryWrapper<OjJudgeRecord> lambdaQueryWrapper) {
            // 测评时间降序
            lambdaQueryWrapper.orderByDesc(OjJudgeRecord::getJudgeTime);
        }
    },
    /**
     * 最优解
     * 按照执行时间升序，占用内存升序
     */
    OPTIMAL("Optimal") {
        @Override
        public void addCondition(LambdaQueryWrapper<OjJudgeRecord> lambdaQueryWrapper) {
            lambdaQueryWrapper.orderByAsc(OjJudgeRecord::getUseTime, OjJudgeRecord::getUseMemory);
        }
    };
    private final String type;

    SortType(String type) {
        this.type = type;
    }

    public abstract void addCondition(LambdaQueryWrapper<OjJudgeRecord> lambdaQueryWrapper);

    public String getType() {
        return type;
    }
}